/**
 * <copyright>
 * </copyright>
 *
 */
package org.xtext.example.mydsl.myDsl.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.mydsl.myDsl.CampoSubred;
import org.xtext.example.mydsl.myDsl.MyDslPackage;
import org.xtext.example.mydsl.myDsl.Subred;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Subred</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SubredImpl#getInt <em>Int</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SubredImpl#getSegundo <em>Segundo</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SubredImpl#getTercero <em>Tercero</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SubredImpl#getCuarto <em>Cuarto</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SubredImpl extends MinimalEObjectImpl.Container implements Subred
{
  /**
   * The default value of the '{@link #getInt() <em>Int</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInt()
   * @generated
   * @ordered
   */
  protected static final int INT_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getInt() <em>Int</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInt()
   * @generated
   * @ordered
   */
  protected int int_ = INT_EDEFAULT;

  /**
   * The cached value of the '{@link #getSegundo() <em>Segundo</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSegundo()
   * @generated
   * @ordered
   */
  protected CampoSubred segundo;

  /**
   * The cached value of the '{@link #getTercero() <em>Tercero</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTercero()
   * @generated
   * @ordered
   */
  protected CampoSubred tercero;

  /**
   * The cached value of the '{@link #getCuarto() <em>Cuarto</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCuarto()
   * @generated
   * @ordered
   */
  protected CampoSubred cuarto;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SubredImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MyDslPackage.Literals.SUBRED;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getInt()
  {
    return int_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInt(int newInt)
  {
    int oldInt = int_;
    int_ = newInt;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SUBRED__INT, oldInt, int_));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CampoSubred getSegundo()
  {
    return segundo;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSegundo(CampoSubred newSegundo, NotificationChain msgs)
  {
    CampoSubred oldSegundo = segundo;
    segundo = newSegundo;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.SUBRED__SEGUNDO, oldSegundo, newSegundo);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSegundo(CampoSubred newSegundo)
  {
    if (newSegundo != segundo)
    {
      NotificationChain msgs = null;
      if (segundo != null)
        msgs = ((InternalEObject)segundo).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SUBRED__SEGUNDO, null, msgs);
      if (newSegundo != null)
        msgs = ((InternalEObject)newSegundo).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SUBRED__SEGUNDO, null, msgs);
      msgs = basicSetSegundo(newSegundo, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SUBRED__SEGUNDO, newSegundo, newSegundo));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CampoSubred getTercero()
  {
    return tercero;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTercero(CampoSubred newTercero, NotificationChain msgs)
  {
    CampoSubred oldTercero = tercero;
    tercero = newTercero;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.SUBRED__TERCERO, oldTercero, newTercero);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTercero(CampoSubred newTercero)
  {
    if (newTercero != tercero)
    {
      NotificationChain msgs = null;
      if (tercero != null)
        msgs = ((InternalEObject)tercero).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SUBRED__TERCERO, null, msgs);
      if (newTercero != null)
        msgs = ((InternalEObject)newTercero).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SUBRED__TERCERO, null, msgs);
      msgs = basicSetTercero(newTercero, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SUBRED__TERCERO, newTercero, newTercero));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CampoSubred getCuarto()
  {
    return cuarto;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCuarto(CampoSubred newCuarto, NotificationChain msgs)
  {
    CampoSubred oldCuarto = cuarto;
    cuarto = newCuarto;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.SUBRED__CUARTO, oldCuarto, newCuarto);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCuarto(CampoSubred newCuarto)
  {
    if (newCuarto != cuarto)
    {
      NotificationChain msgs = null;
      if (cuarto != null)
        msgs = ((InternalEObject)cuarto).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SUBRED__CUARTO, null, msgs);
      if (newCuarto != null)
        msgs = ((InternalEObject)newCuarto).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SUBRED__CUARTO, null, msgs);
      msgs = basicSetCuarto(newCuarto, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SUBRED__CUARTO, newCuarto, newCuarto));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDslPackage.SUBRED__SEGUNDO:
        return basicSetSegundo(null, msgs);
      case MyDslPackage.SUBRED__TERCERO:
        return basicSetTercero(null, msgs);
      case MyDslPackage.SUBRED__CUARTO:
        return basicSetCuarto(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MyDslPackage.SUBRED__INT:
        return getInt();
      case MyDslPackage.SUBRED__SEGUNDO:
        return getSegundo();
      case MyDslPackage.SUBRED__TERCERO:
        return getTercero();
      case MyDslPackage.SUBRED__CUARTO:
        return getCuarto();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MyDslPackage.SUBRED__INT:
        setInt((Integer)newValue);
        return;
      case MyDslPackage.SUBRED__SEGUNDO:
        setSegundo((CampoSubred)newValue);
        return;
      case MyDslPackage.SUBRED__TERCERO:
        setTercero((CampoSubred)newValue);
        return;
      case MyDslPackage.SUBRED__CUARTO:
        setCuarto((CampoSubred)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.SUBRED__INT:
        setInt(INT_EDEFAULT);
        return;
      case MyDslPackage.SUBRED__SEGUNDO:
        setSegundo((CampoSubred)null);
        return;
      case MyDslPackage.SUBRED__TERCERO:
        setTercero((CampoSubred)null);
        return;
      case MyDslPackage.SUBRED__CUARTO:
        setCuarto((CampoSubred)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.SUBRED__INT:
        return int_ != INT_EDEFAULT;
      case MyDslPackage.SUBRED__SEGUNDO:
        return segundo != null;
      case MyDslPackage.SUBRED__TERCERO:
        return tercero != null;
      case MyDslPackage.SUBRED__CUARTO:
        return cuarto != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (int: ");
    result.append(int_);
    result.append(')');
    return result.toString();
  }

} //SubredImpl
